package com.ruoyi.web.controller.intelligence;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.json.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.intelligence.chat.baidu.SerBFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Author: wxj
 * 百度云
 * @Date: 2023/11/23
 */
@SaIgnore
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("intelligence/bdy")
public class BDYController {

    @Autowired
    private SerBFactory serBFactory;

    @GetMapping("/login")
    public R<String> login() {
        String accessToken = serBFactory.getAccessToken();
        return R.ok(accessToken);
    }


    /**
     * 文本生成图片
     * @param msg
     * @return
     */
    @GetMapping("/stable")
    public R<List<JSONObject> > stable(@RequestParam String msg) {
        List<JSONObject>  data = serBFactory.stable(msg);
        return R.ok(data);
    }

    /**
     * 对话
     * @param msgs
     * @return
     */
    @PostMapping("/ERNIEBot4")
    public R<String> ERNIEBot4(@RequestBody List<String> msgs) {
        String data = serBFactory.ERNIEBot4(msgs);
        return R.ok(data);
    }

}
